# Maintainer: Leon White <badfunkstripe@gmail.com>
pkgname=eccodes
pkgver=2.32.1
pkgrel=0
pkgdesc="API and tools for decoding and encoding WMO meteorological message formats"
url="https://github.com/ecmwf/eccodes"
# ecCodes only supports 64 bit platforms
# s390x blocked by netcdf-dev
arch="all !armhf !armv7 !s390x !x86"
license="Apache-2.0"
makedepends="
	cmake
	gfortran
	git
	jasper-dev
	jpeg-dev
	libaec-dev
	netcdf-dev
	openjpeg-dev
	perl
	py3-numpy
	python3
	"

source="
	eccodes-$pkgver-Source.tar.gz::https://confluence.ecmwf.int/download/attachments/45757960/eccodes-$pkgver-Source.tar.gz?api=v2
	https://get.ecmwf.int/repository/test-data/eccodes/eccodes_test_data.tar.gz
"

builddir="$srcdir/$pkgname-$pkgver-Source"

build() {
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
		-DCMAKE_INSTALL_LOCALSTATEDIR=/var \
		-DENABLE_EXTRA_TESTS=ON
	cmake --build build
}

check() {
	ctest --test-dir build
}

package() {
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
7fdb34cee0b656ebbecc04d654642b0524eb6e772c1d811471061698f4ec2d31da3be3d66ee697dd3e106f3e8024058b4c165c6dad59868af66a38949c956c77  eccodes-2.32.1-Source.tar.gz
86767a308841849c7ece006e9f6c68123dc07d8640b038e25529b91ab495d3f10ad5356e9100ef238de6756c67917be13a676f4ab0708fb381021c746e00183e  eccodes_test_data.tar.gz
"
